import React, { Component } from 'react';
import {Image, View,Dimensions,StyleSheet,AppRegistry,Platform,WebView,} from 'react-native';
import STRING from '../../const_string_zh_CN';
import { NavigationActions } from 'react-navigation'
import { Container, Content, List, ListItem, Thumbnail, Text, Body, Icon, Button } from 'native-base';
import { get_location } from '../../net/map.js'
import { MapView, MapTypes, MapModule, Geolocation } from 'react-native-baidu-map'
const { width, height } = Dimensions.get('window');
const marginTop = Platform.OS === 'ios' ? 20 : 0;
let mapSource;
let lineSource;
export default class tab_me extends Component {
    state = {
        zoom: 15,
        current_data: [],
        marks: [],
        center: {
            longitude: 114.364,
            latitude: 30.523
        },
    };
    async componentWillMount() {
        let data = await get_location();
        console.log('1233423', data);
        marks = []
        data.map((v) => {
            console.log("locate", v.myLatitude, v.myLongitude);
            marks.push({ latitude: parseFloat(v.myLatitude), longitude: parseFloat(v.myLongitude), title: v.myUserID })
        });
        this.setState({ current_data: data, marks: marks });
    }
    render() {
        return (
            <Content>
                <List style={StyleSheet.flatten(styles.list)}>
                    <ListItem>
                        <Text>当前在线人数：</Text>
                        <Text>{this.state.current_data.length}人</Text>
                    </ListItem>

                </List>
                <MapView baiduHeatMapEnabled
                    style={{ width: width, height: height - 200 }}
                    mapType={1}
                    zoom={this.state.zoom}
                    center={this.state.center}
                    markers={this.state.marks}></MapView>
            </Content>
        );
    }
}
const styles = StyleSheet.create({
    button_default: {
        marginTop: 60,
        width: width / 2,
        alignSelf: 'center',
        backgroundColor: 'white',
    },
    form_style: {
        width: width / 2,
        alignItems: 'center',
        alignSelf: 'center',
    },
    list: {
        marginTop: 10,
        marginRight: 5,
        marginLeft: 5,
        backgroundColor: 'white',

    },
});
